package com.yx.websocketim

import android.content.Context
import android.content.Intent
import androidx.multidex.MultiDexApplication

/**
 * Creator:Yx
 * Time:2022/7/13 16:22
 * Description:
 */
class YxApplication : MultiDexApplication() {

    /**
     * 单例 - 静态内部类
     */
    companion object {
        fun getInstance() = Holder.holder
        var instance: Context? = null

        // Service 中的广播约定 ,理论上应该在Service中初始
        var intent: Intent = Intent("com.yx.websocketim.RECEIVER")
    }

    private object Holder {
        val holder = YxApplication()
    }


    override fun onCreate() {
        super.onCreate()
        instance = this
        // 静态注册的广播发送内容需要增加如下代码，详细说明看Manifest
        intent.setClassName(packageName, "$packageName.MsgReceiver")


        // 动态注册广播
        // val intents: IntentFilter = IntentFilter("com.example.communication.RECEIVER")
        // val receiver: MsgReceiver = MsgReceiver()
        // this.registerReceiver(receiver, intents)
    }

}